package com.jic.interaction.clearAndSettlementSystem.common.util;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author bourne
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class RestResult<T> implements Serializable {

    private static final String SUCCESS_CODE = "13010000";
    private static final String SUCCESS_MESSAGE = "请求成功";
    private static final String ERROR_MESSAGE = "请求失败";
   // private static final String ERROR_CODE = "12010000";


    private String code;//13010000：成功，其他失败
    private String msg;


    public static RestResult error(String code, String message) {
        return RestResult.builder()
                .code(code)
                .msg(message)
                .build();
    }
    public static RestResult success(String code, String message) {
        return RestResult.builder()
                .code(SUCCESS_CODE)
                .msg(message)
                .build();
    }


    public static boolean checkIsSuccess(RestResult restResult) {
        if (restResult != null && SUCCESS_CODE.equals(restResult.getCode())) {
            return true;
        }
        return false;
    }
}
